package com.xmut.controller;

import com.xmut.pojo.Appointment;
import com.xmut.pojo.Result;
import com.xmut.service.AppointmentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author zhangbaiyan
 * @date 2024-06-04 20:59
 * @description:
 * @version:
 */
@Slf4j
@RestController
@CrossOrigin("*")
public class AppointmentController {
    @Autowired
    private AppointmentService appointmentService;
    @PostMapping("/hospital")
    public Result add(@RequestBody Appointment appointment){
        log.info("新增内容{}",appointment);
        appointmentService.add(appointment);
        return Result.success();
    }

    @GetMapping("/getAllHospital")
    public Result getAllHospital()
    {
       List<Appointment> appointments = appointmentService.getAllHospital();
        return Result.success(appointments);
    }


    @DeleteMapping("/delHospitalById/{id}")
    public Result delHospitalById(@PathVariable Integer id)
    {
        appointmentService.delHospitalById(id);
        return Result.success();
    }


}
